<template>
  <div class="base-dialog" v-if="props.visible">
    <div class="header">
      <el-button @click="cancel"> 取消 </el-button>
    </div>
    <slot />
    <div class="footer">
      <el-button @click="submit">确定 </el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ElButton } from "element-plus";
const props = defineProps({
  visible: {
    type: Boolean,
    default: false,
  },
  cancelCallBack: {
    type: Function,
    default: () => {},
  },
  confirmCallBack: {
    type: Function,
    default: () => {},
  },
});
const emit = defineEmits(["update:visible"]);
function close() {
  console.log("close");

  emit("update:visible", false);
}
function cancel() {
  props.cancelCallBack(close);
}
function submit() {
  props.confirmCallBack(close);
}
</script>

<style lang="scss" scoped>
.base-dialog {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff;
}
</style>
